mir: pass motion events down to transient children
authorWilliam Hua <william@attente.ca>
Mon, 1 Dec 2014 13:54:13 +0000 (08:54 -0500)
committerWilliam Hua <william@attente.ca>
Thu, 5 Feb 2015 16:26:17 +0000 (17:26 +0100)
gdk/mir/gdkmir-private.h
gdk/mir/gdkmireventsource.c
gdk/mir/gdkmirwindowimpl.c

index 053615a2108c3e07c493b871eed7418b67091bd3..9361b729779edecebb7acd7b98f69b932dc902ef 100644 (file)
@@ -131,4 +131,11 @@ void _gdk_mir_print_resize_event (const MirResizeEvent *event);
 
 void _gdk_mir_print_event (const MirEvent *event);
 
+/* TODO: Remove once we have proper transient window support. */
+GdkWindow * _gdk_mir_window_get_transient_child (GdkWindow *window,
+                                                 gint       x,
+                                                 gint       y,
+                                                 gint      *out_x,
+                                                 gint      *out_y);
+
 #endif /* __GDK_PRIVATE_MIR_H__ */
index cfe36e8df558f91ba540912c5dda42cfe60d93c9..20b7972171d9421d82869a158b8e746b462ff18b 100644 (file)
@@ -459,7 +459,31 @@ gdk_mir_event_source_convert_events (GdkMirEventSource *source)
        * event was being dispatched...
        */
       if (window != NULL)
-        gdk_mir_event_source_queue_event (source->display, window, &event->event);
+        {
+          /* TODO: Remove once we have proper transient window support. */
+          if (event->event.type == mir_event_type_motion)
+            {
+              GdkWindow *child;
+              gint x;
+              gint y;
+
+              x = event->event.motion.pointer_coordinates[0].x;
+              y = event->event.motion.pointer_coordinates[0].y;
+
+              child = _gdk_mir_window_get_transient_child (window, x, y, &x, &y);
+
+              if (child && child != window)
+                {
+                  window = child;
+
+                  event->event.motion.pointer_count = MAX (event->event.motion.pointer_count, 1);
+                  event->event.motion.pointer_coordinates[0].x = x;
+                  event->event.motion.pointer_coordinates[0].y = y;
+                }
+            }
+
+          gdk_mir_event_source_queue_event (source->display, window, &event->event);
+        }
       else
         g_warning ("window was destroyed before event arrived...");
 
index 6431ed4f0f50c4532719ac01850d7b2b52ac489b..78c51118eed2cc354606ab35fb29869aaba97ed9 100644 (file)
@@ -910,6 +910,37 @@ gdk_mir_window_impl_set_transient_for (GdkWindow *window,
   ensure_no_surface (window);
 }
 
+/* TODO: Remove once we have proper transient window support. */
+GdkWindow *
+_gdk_mir_window_get_transient_child (GdkWindow *window,
+                                     gint       x,
+                                     gint       y,
+                                     gint      *out_x,
+                                     gint      *out_y)
+{
+  GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
+  GdkWindow *child = NULL;
+  GList *i;
+
+  if (x < window->x || x >= window->x + window->width ||
+      y < window->y || y >= window->y + window->height)
+    return NULL;
+
+  x -= window->x;
+  y -= window->y;
+
+  for (i = impl->transient_children; i && !child; i = i->next)
+    child = _gdk_mir_window_get_transient_child (i->data, x, y, out_x, out_y);
+
+  if (child)
+    return child;
+
+  *out_x = x;
+  *out_y = y;
+
+  return window;
+}
+
 static void
 gdk_mir_window_impl_get_frame_extents (GdkWindow    *window,
                                        GdkRectangle *rect)